# Maintainer: Alexey Kasatkin <alexeikasatkin@gmail.com>
# ArchLinux maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

_realname=sparsehash
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.4
pkgrel=1
pkgdesc="Library that contains several hash-map implementations, including implementations that optimize for space or speed (mingw-w64)"
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/sparsehash/sparsehash"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' '!libtool')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/sparsehash/sparsehash/archive/${_realname}-${pkgver}.tar.gz")
sha256sums=('8cd1a95827dfd8270927894eb77f62b4087735cbede953884647f16c521c7e58')

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -k check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  install -D -m644 "${srcdir}/${_realname}-${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
